package edu.mis.modules.role;

        import com.jfinal.aop.Interceptor;
        import com.jfinal.aop.Invocation;
        import com.jfinal.core.Controller;

public class RoleInterceptor implements Interceptor {
    public void intercept( Invocation invocation){
        Controller controller=invocation.getController();
        String roleId=controller.getSessionAttr("loginRoleId"); //从session中得到登录用户名
        if(roleId.equals("1")){
            invocation.invoke();  //拦截校验通过，继续执行
        }else{
            controller.redirect("/index");  //跳转到首页
        }
    }
}
